package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.PdfDocument;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IPdfDocumentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * pdf签章Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/pdfDocument")
public class PdfDocumentController extends BaseController
{
    @Autowired
    private IPdfDocumentService pdfDocumentService;

    /**
     * 查询pdf签章列表
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdfDocument pdfDocument)
    {
        startPage();
        List<PdfDocument> list = pdfDocumentService.selectPdfDocumentList(pdfDocument);
        return getDataTable(list);
    }

    /**
     * 导出pdf签章列表
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:export')")
    @Log(title = "pdf签章", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PdfDocument pdfDocument)
    {
        List<PdfDocument> list = pdfDocumentService.selectPdfDocumentList(pdfDocument);
        ExcelUtil<PdfDocument> util = new ExcelUtil<PdfDocument>(PdfDocument.class);
        return util.exportExcel(list, "pdf签章数据");
    }

    /**
     * 获取pdf签章详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:query')")
    @GetMapping(value = "/{documentcode}")
    public AjaxResult getInfo(@PathVariable("documentcode") String documentcode)
    {
        return AjaxResult.success(pdfDocumentService.selectPdfDocumentByDocumentcode(documentcode));
    }

    /**
     * 新增pdf签章
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:add')")
    @Log(title = "pdf签章", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdfDocument pdfDocument)
    {
        return toAjax(pdfDocumentService.insertPdfDocument(pdfDocument));
    }

    /**
     * 修改pdf签章
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:edit')")
    @Log(title = "pdf签章", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PdfDocument pdfDocument)
    {
        return toAjax(pdfDocumentService.updatePdfDocument(pdfDocument));
    }

    /**
     * 删除pdf签章
     */
    @PreAuthorize("@ss.hasPermi('system:pdfDocument:remove')")
    @Log(title = "pdf签章", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentcodes}")
    public AjaxResult remove(@PathVariable String[] documentcodes)
    {
        return toAjax(pdfDocumentService.deletePdfDocumentByDocumentcodes(documentcodes));
    }
}
